<?php
    function ThongBaoLoi($thongbaoloi="")
    {
        echo "<h3>Lỗi</h3><p class='ThongBaoLoi'>$thongbaoloi</p>";
    }
    
    function ThongBao($thongbao="")
    {
        echo "<h3>Hoàn thành</h3><p class='ThongBao'>$thongbao</p>";
    }
    
    function KiemTraNgay(&$chuoingay)
    {
        // Input: 22/02/2013
        $arr = explode("/", $chuoingay);

        $ngay = (int)$arr[0];
        $thang = (int)$arr[1];
        $nam = (int)$arr[2];

        if(checkdate($thang, $ngay, $nam))
        {
            // Output: 2013-02-22
            $chuoingay = "$nam-$thang-$ngay";

            return true;
        }
        else
        {
            return false;
        }
    }
	
	function InNgay($chuoingay)
	{
    // Input: 22/02/2013
    $arr = explode("-", $chuoingay);

    $nam = $arr[0];
    $thang = $arr[1];
    $A = $arr[2];

    $arr1 = explode(" ", $A);
    $ngay = $arr1[0];
    $time = $arr1[1];

    $datetime = $ngay . "/" . $thang . "/" . $nam . ", " . $time;

    return $datetime;
}

function PhanTrang($totalrows = 0, $start = 0, $limit = 10, $link = "")
{
    if($totalrows > $limit)
    {
            echo "<ul class='PhanTrang'>";

            if($start > 0)
            {
                    echo "<li class='arrowleft'><a href='" . $link . ($start - $limit) . "'>&nbsp;</a></li>";
            }

            $page = 1;
            for($i = 0; $i < $totalrows; $i = $i + $limit)
            {
                    if($i == $start) echo "<li class='active'><a href='" . $link . $i . "'>{$page}</a></li>";
                    else echo "<li><a href='" . $link . $i . "'>{$page}</a></li>";
                    $page++;
            }

            if($start < $totalrows - $limit)
            {
                    echo "<li class='arrowright'><a href='" . $link . ($start + $limit) . "'>&nbsp;</a></li>";
            }

            echo "</ul>";
            }
    }
?>

